#!/bin/bash
#This is a backup script for Oracle.
#for 
# File save time is 7 days.
#system test1 test2 is oracle user
#pwd is oracle passwd
bapath="/home/oracle/DBfile/"
if [ ! -d $bapath ];then
  mkdir -p $bapath
fi
filename=`date +%Y-%m-%d`'.bmp'
logname=`date +%Y-%m-%d`'.log'

for user in system test1 test2
do 
	pwd="123.com"
	exp ${user}/${pwd}@orcl file=${bapath}${user}-${filename} log=${bapath}${user}-$logname
	cd $bapath
	tar zcf ${user}-$filename.tar.gz ${user}-$filename
	tar zcf ${user}-$logname.tar.gz ${user}-$logname
	find $bapath -mtime +7 -name "*.bmp.tar.gz" -exec rm -rf {} \;
	find $bapath -mtime +7 -name "*.log.tar.gz" -exec rm -rf {} \;
done
rm -rf ${bapath}*.bmp
rm -rf ${bapath}*.log

